
package root.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.datepicker.client.DateBox;
import com.google.gwt.user.client.ui.TextBox;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */

public class Plumbum implements EntryPoint {
	
	private Button clickMeButton2;
	private final GreetingServiceAsync sys = GWT.create(GreetingService.class);
	
	public void onModuleLoad() {
		
		
		final Label label  = new Label("");
		
		

		
		RootPanel rootPanel = RootPanel.get();
		rootPanel.add(label);
		
		clickMeButton2 =  new Button();
		rootPanel.add(clickMeButton2, 418, 395);
		clickMeButton2.setText("Criar usuario");
		clickMeButton2.setSize("111px", "24px");
		
		final TextArea textArea = new TextArea();
		rootPanel.add(textArea, 470, 263);
		textArea.setSize("108px", "21px");
		
		final TextArea textArea_1 = new TextArea();
		rootPanel.add(textArea_1, 470, 300);
		textArea_1.setSize("108px", "21px");
		
		final TextArea textArea_2 = new TextArea();
		rootPanel.add(textArea_2, 470, 342);
		textArea_2.setSize("108px", "21px");
		
		TextBox txtbxLogin = new TextBox();
		txtbxLogin.setText("Login");
		rootPanel.add(txtbxLogin, 398, 263);
		txtbxLogin.setSize("56px", "19px");
		
		TextBox txtbxNome = new TextBox();
		txtbxNome.setText("Nome");
		rootPanel.add(txtbxNome, 398, 300);
		txtbxNome.setSize("54px", "19px");
		
		TextBox txtbxEndereco = new TextBox();
		txtbxEndereco.setText("Endereco");
		rootPanel.add(txtbxEndereco, 398, 342);
		txtbxEndereco.setSize("56px", "19px");
		
		clickMeButton2.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				
				try{
				sys.criarUsuario(textArea.getText(), textArea_1.getText(),textArea_2.getText(), new AsyncCallback<Void>() {

					@Override
					public void onFailure(Throwable caught) {
						label.setText(caught.getMessage());
						Window.alert(caught.getMessage());
						
					}
					@Override
					public void onSuccess(Void result) {
						label.setText("Criou");
					}
				});
				}catch(Exception e){
					label.setText(e.getMessage());
				}
			}
		});
		
	}
}
